Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/socket.io

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/socket.io

TypeScript definitions for socket.io

  • 2.1.13
  • ts3.4
  • ts3.5
  • ts3.6
  • ts3.7
  • ts3.8
  • ts3.9
  • ts4.0
  • ts4.1
  • ts4.2
  • ts4.3
  • npm
  • Socket score

Version published
Weekly downloads
181K
increased by9.86%
Maintainers
1
Weekly downloads
 
Created

What is @types/socket.io?

@types/socket.io provides TypeScript type definitions for the Socket.IO library, which is used for real-time, bidirectional communication between web clients and servers.

What are @types/socket.io's main functionalities?

Server-Side Socket Handling

This feature allows you to set up a Socket.IO server that listens for client connections and disconnections.

const io = require('socket.io')(3000);
io.on('connection', (socket) => {
  console.log('a user connected');
  socket.on('disconnect', () => {
    console.log('user disconnected');
  });
});

Client-Side Socket Handling

This feature allows you to set up a Socket.IO client that connects to a server and listens for connection and disconnection events.

const socket = io('http://localhost:3000');
socket.on('connect', () => {
  console.log('connected to server');
});
socket.on('disconnect', () => {
  console.log('disconnected from server');
});

Emitting and Listening to Events

This feature allows you to emit and listen to custom events between the server and client.

const io = require('socket.io')(3000);
io.on('connection', (socket) => {
  socket.on('chat message', (msg) => {
    io.emit('chat message', msg);
  });
});

const socket = io('http://localhost:3000');
socket.emit('chat message', 'Hello World');
socket.on('chat message', (msg) => {
  console.log('message: ' + msg);
});

Other packages similar to @types/socket.io

FAQs

Package last updated on 25 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc